/*
 * FormTemplate.java
 *
 * Copyright (c) 2008 Teamnet. All Rights Reserved.
 *
 * This source file may not be copied, modified or redistributed,
 * in whole or in part, in any form or for any reason, without the express
 * written consent of Teamnet.
 */
package ro.prjmanager.template.form;

import ro.prjmanager.bundle.BundleClReader;
import static ro.prjmanager.constants.BackendConstants.*;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * This class is an form for the template files
 */
public class FormTemplate {

    //the factory company name
    private String companyName;
    //the author that generate this file
    private String author;
    //the version of the generated file
    private String version;
    //the year of the file generation
    private String year;
    //the base path where are generating all files
    private String basePath;
    //holds the bundle object that is containing all properties
    // from application.config.properties file
    protected BundleClReader bundle;
    //holds the relative template file path
    protected String templatePath;
    //the directory from root path where are generating all files
    private String directoryGen;
    public FormTemplate() {
        bundle= BundleClReader.getInstance(APPLICATION_CONFIG_PATH+"/"+APPLICATION_CONFIG_NAME);
        this.companyName = bundle.getString(APPLICATION_GENERAL_COMPANY);
        this.author = bundle.getString(APPLICATION_GENERAL_USER);
        this.version = bundle.getString(APPLICATION_GENERAL_VERSION);
        this.basePath=bundle.getString(GENERATION_BASE_PATH);
        Date today = new Date();
        SimpleDateFormat sdf=new SimpleDateFormat(JAVA_DATE_PATTERN);
        directoryGen=bundle.getString(GENERATION_DIRECTORY_PATTERN)+sdf.format(today);
        File ff=new File(basePath+ PATH_SEPARATOR +directoryGen);
        if(!ff.exists())
            ff.mkdirs();

        Calendar cal = new GregorianCalendar();
        cal.setTime(today);
        year = String.valueOf(cal.get(Calendar.YEAR));
    }




    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public BundleClReader getBundle() {
        return bundle;
    }

    public void setBundle(BundleClReader bundle) {
        this.bundle = bundle;
    }

    public String getBasePath() {
        return basePath;
    }

    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }

    public String getTemplatePath() {
        return templatePath;
    }

    public void setTemplatePath(String templatePath) {
        this.templatePath = templatePath;
    }

    public String getDirectoryGen() {
        return directoryGen;
    }

    public void setDirectoryGen(String directoryGen) {
        this.directoryGen = directoryGen;
    }
}
